package board.comment.dao;

import java.sql.SQLException;
import java.util.List;

import board.comment.dto.CommentDto;

import util.SqlMapLocator;

public class CommentDao {
	private static CommentDao instance = new CommentDao();
	public static CommentDao getInstance() { return instance; }
	private CommentDao() {}
	
	@SuppressWarnings("unchecked")
	public List<CommentDto> list(int article_no) throws SQLException {
		return (List<CommentDto>)SqlMapLocator.getMapper().queryForList("comment.selectAll", article_no);
	}
	
	public void insert(CommentDto dto) throws SQLException {
		SqlMapLocator.getMapper().insert("comment.insert", dto);
	}
	
	public void delete(int comment_no) throws SQLException {
		SqlMapLocator.getMapper().delete("comment.delete", comment_no);
	}
	
	public void updateCountUP(int article_no) throws SQLException {
		SqlMapLocator.getMapper().update("comment.updateCountUP", article_no);
	}
	public void updateCountDOWN(int article_no) throws SQLException {
		SqlMapLocator.getMapper().update("comment.updateCountUP", article_no);
	}
}
